import 'package:flutter/material.dart';
import 'package:hi_flutter/app_page.dart';

class NestedScrollViewDemoPage extends StatelessWidget {
  const NestedScrollViewDemoPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Material(
      child: NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return <Widget> [
            // 实现 snap 效果
            SliverAppBar(
              pinned: true,
              expandedHeight: 200,
              forceElevated: innerBoxIsScrolled,
              flexibleSpace: FlexibleSpaceBar(
                background: Image.asset(
                  "images/pic20.jpg",
                  fit: BoxFit.cover,
                ),
              ),
            )
          ];
        },
        body: Builder(builder: (BuildContext context) {
          return CustomScrollView(
            slivers: <Widget>[
              SliverFixedExtentList(
                  itemExtent: 56, //列表项高度固定
                  delegate: SliverChildBuilderDelegate(
                        (_, index) => ListTile(title: Text('$index')),
                    childCount: 50,
                  )
              ),
            ],
          );
        }),
      ),
    );
  }
}
